#ifndef MAP_H
#define MAP_H

#include <set>
#include "MapPoint.h"
#include "KeyFrame.h"

class MapPoint;
class KeyFrame;

class Map
{
public:
	Map();
	~Map();

	void AddMapPoint(MapPoint* pMP);

	void EraseMapPoint(MapPoint* pMP);

	void AddKeyFrame(KeyFrame* pKF);

	void EraseKeyFrame(KeyFrame* pKF);

	void SetReferenceMapPoints(const std::vector<MapPoint*> &vpMPs);

	void InformNewBigChange();

	int GetLastBigChangeIdx();

	std::vector<KeyFrame*> GetAllKeyFrames();

	std::vector<MapPoint*> GetAllMapPoints();

	std::vector<MapPoint*> GetReferenceMapPoints();

	long unsigned int MapPointsSize();

	long unsigned  KeyFramesSize();

	long unsigned int GetMaxKFid();

	void clear();

	std::vector<KeyFrame*> m_vectorKeyFrameOrigins;

	std::mutex m_MutexMapUpdate;

	// This avoid that two points are created simultaneously in separate threads (id conflict)
	std::mutex m_MutexPointCreation;

protected:
	std::set<MapPoint*> m_setMapPoints;
	std::set<KeyFrame*> m_setKeyFrames;

	std::vector<MapPoint*> m_vectorReferenceMapPoints;

	long unsigned int m_MaxKeyFrameId;

	// Index related to a big change in the map (loop closure, global BA)
	int m_BigChangeIdx;

	std::mutex m_MutexMap;

};
#endif //MAP_H

